<template>
	<view class="recordBox">
		<view style="padding: 20%;" v-if="dataList.length == 0">无记录</view>
		<view class="recordItem" v-for="(item,index) in dataList">
			<view class="title">医疗记录</view>
			<view class="contentList">
				<view class="contentItem">
					<view class="label">订单号</view>
					<view class="value">{{item.id}}</view>
				</view>
				<view class="contentItem">
					<view class="label">就诊人</view>
					<view class="value">{{item.usrName}}</view>
				</view>
				<view class="contentItem">
					<view class="label">预约时间</view>
					<view class="value">{{item.beginTime}}</view>
				</view>
				<view class="contentItem">
					<view class="label">预约医师</view>
					<view class="value">{{item.drName}}</view>
				</view>
				<view class="contentItem">
					<view class="label">就诊科室</view>
					<view class="value">{{item.deptName}}</view>
				</view>
				<view class="contentItem">
					<view class="label">挂号费</view>
					<view class="value">{{item.price}}元</view>
				</view>
				<view class="contentItem">
					<view class="label">就诊状态</view>
					<view class="value">{{ stateName[item.state] }}</view>
				</view>
			</view>
			<view v-if="item.state == 2" class="showDetail" @click="toReview(item)">查看</view>
			
		</view>
	</view>
</template>

<script>
	import appRequest from "@/common/appRequestUrl.js";
	export default {
		data() {
			return {
				user:{},
				dataList:[],
				stateName:['未交费','待诊断','已完成','已过期']
			}
		},onLoad() {
			this.user = appRequest.getUserInfo();
			if(!this.user){
				uni.redirectTo({
					url:"/pages/login/login"
				})
			}
			this.getData();
		},
		methods: {
			toReview(item){
				uni.navigateTo({
					url:"/pages/registrationRecord/recordItem?param="+JSON.stringify(item)
				})
			},
			calcle(item){
				let _this = this;
				appRequest.request({
					method: "POST",
					data: {
						id:item,
						validFlag:0
					},
					url: appRequest.urlMap.editNmHosiptalRegister,
					success: function(res) {
						if(res.data.code == 200){
							_this.getData();
						}else{
							_this.$api.msg(res.data.msg);
						}
					},
					fail: function(res) {
						_this.$api.msg("请求异常");
					}
				})
			},
			// 挂号记录详情
			registrationDetail(){
				
				uni.navigateTo({
					url:'/pages/registrationDetail/registrationDetail'
				})
			},
			getData(){
				let _this = this;
				
				var param = {
					validFlag:1
				}
				
				if(this.user.type == 2){
					param['usrFk'] = this.user.uid;
				}else if(this.user.type == 3){
					param['drFk'] = this.user.uid;
				}
				
				appRequest.request({
					method: "POST",
					data: param,
					url: appRequest.urlMap.findNmHosiptalRegisterList,
					success: function(res) {
						if(res.data.code == 200){
							var his = res.data.data;
							var list = [];
							his.map(function(item,idnex){
								if(item.state != 1){
									list.push(item);
								}
							})
							
							_this.dataList = list;
							
							
						}else{
							_this.$api.msg(res.data.msg);
						}
					},
					fail: function(res) {
						_this.$api.msg("请求异常");
					}
				})
				
			}
		},
	}
</script>
<style>
	page{
		width: 100%;
		height: 100%;
		background: #F8F8F8;
	}
</style>
<style scoped lang="scss">
	.recordBox{
		height: 100%;
		padding: 0 40rpx;
		.recordItem{
			margin-top: 20rpx;
			background-color: #FFFFFF;
			.title{
				height: 66rpx;
				padding: 0 20rpx;
				line-height: 66rpx;
				background: #E1E1E1;
				font-size: 32rpx;
				color: #141414;
			}
			.contentList{
				display: flex;
				flex-direction: column;
				font-size: 28rpx;
				color: #6D6D6D;
				.contentItem{
					display: flex;
					align-items: center;
					justify-content: space-between;
					border-bottom: 1px dashed #C1C1C1;
					height: 66rpx;
					padding: 0 20rpx;
					line-height: 66rpx;
				}
			}
			.showDetail{
				color: #548AFB;
				padding: 20rpx 0;
				display: flex;
				align-items: center;
				justify-content: center;
			}
		}
	}
</style>
